from django.db import models
from datetime import datetime

#基类
class Base(models.Model):

    #创建事件
    create_time = models.DateTimeField(default=datetime.now(),null=True)

    class Meta:
        abstract = True


#用户类
class User(Base):

    #用户名
    username = models.CharField(max_length=200)
    #密码
    password = models.CharField(max_length=200)
    #头像
    img = models.CharField(max_length=200)
    #类别  0普通用户 1超级管理员
    type = models.IntegerField()

    class Meta:
        db_table = "user"

#幻灯片
class Pics(Base):

    #名称
    title = models.CharField(max_length=200)
    #链接
    link = models.CharField(max_length=200)
    #图片
    img = models.CharField(max_length=200)

    class Meta:
        db_table = "pics"
    

    
#商品表
class Goods(Base):

    #商品名称
    name = models.CharField(max_length=200)
    #商品简介
    desc = models.CharField(max_length=500)
    #商品规格
    parms = models.CharField(max_length=500)
    #商品头图
    img = models.CharField(max_length=200,null=True)
    #演示视频
    video = models.CharField(max_length=200,null=True)
    #价格
    price = models.IntegerField()
    #关注数
    flow = models.IntegerField(default=0,null=True)
    #分类id
    cate_id = models.IntegerField()

    class Meta:
        db_table = "goods"


#建立用户评论
class Comment(Base):
    #评论内容uid
    content = models.CharField(max_length=200)
    #谁评论的
    uid = models.IntegerField()
    #评论哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table= "comment"

#关注表
class UserFlow(Base):

    #谁关注的
    uid = models.IntegerField()
    #关注的哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table = "userflow"





